package com.blank.shop.nacos.consumer;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * <br/>Date 2021/8/29
 * <br/>Time 15:19:43
 *
 * @author _blank
 */
@RestController
public class ServerConsumerController {
    /**
     * 可以放在配置文件里面做成动态读取
     */
    public static final String PROVIDER_SERVER_URL = "http://blank-shop-alibaba-nacos-provider";

    @Resource
    private RestTemplate restTemplate;

    @GetMapping(path = {"say-hello"})
    public ResponseEntity<String> consumerSayHello() {
        final String url = PROVIDER_SERVER_URL + "/provider-say-hello";
        return this.restTemplate.exchange(url, HttpMethod.POST, HttpEntity.EMPTY, String.class);
    }

}
